package com.zhongshengnetwork.rightbe.dbservice;

import com.zhongshengnetwork.rightbe.CustomApplication;
import com.zhongshengnetwork.rightbe.dbmodel.AtMsgdbModel;
import com.zhongshengnetwork.rightbe.dbmodel.HotLifedbModel;

import org.xutils.DbManager;
import org.xutils.ex.DbException;
import org.xutils.x;

/**
 * Created by luojingxing on 2017/7/2.
 */

public class HotLifedbService {
    //插入或者更新数据
    public static boolean saveOrUpdate(HotLifedbModel model){
        DbManager db = x.getDb(CustomApplication.daoConfig);
        try {
            db.saveOrUpdate(model);
            return true;
        } catch (DbException e) {
            e.printStackTrace();
            return false;
        }
    }

    //获取数据
    public static HotLifedbModel getModel(String id){
        DbManager db = x.getDb(CustomApplication.daoConfig);
        try {
            return db.findById(HotLifedbModel.class,id);
        } catch (DbException e) {
            e.printStackTrace();
            return null;
        }
    }

    //删除数据
    public static boolean deleteModel(String id){
        DbManager db = x.getDb(CustomApplication.daoConfig);
        try {
            db.deleteById(HotLifedbModel.class,id);
            return true;
        } catch (DbException e) {
            e.printStackTrace();
            return false;
        }
    }
}
